package com.myjava.collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
    class Cat{
    String name;
    Cat(String name){
       this.name = name;
    }
   void show(){
       System.out.println(this.name);
   }
}
@SuppressWarnings({"unchecked", "unused"})

public class IteratorClass {
    public static void main(String[] args) {
        ArrayList c1 = new ArrayList();
        c1.add("a");
        c1.add("a");
        c1.add("a");
        c1.add("a");
        Iterator it = c1.iterator();
        while(it.hasNext()){
            System.out.println(it.next());
        }
          Collection c2 = new ArrayList();
          c2.add(new Cat("mimi"));
          c2.add(new Cat("xiaohua"));
          c2.add(new Cat("doudou"));
            Iterator it2 = c2.iterator();
            while (it2.hasNext()){
               Cat cat = (Cat)it2.next();
               cat.show();
            }


    }
}
